<?php
namespace app\admin\controller;
use think\Db;
use app\common\controller\AdminBaseController;
class ConfigController extends AdminBaseController 
{
    public function index()
    {
    	$list=Db::name('admin_system')->select();	
    	for($i=0;$i<count($list);$i++){
    		$value=unserialize($list[$i]['value']);
    		$name[$i]=$list[$i]['name'];
    		$this->assign('config'.$i,$value);
    	}    	
    	
    	return $this->fetch('index',['name'=>$name]);
    }
     public function save()
    {
    	$param=input('post.');
    	if(in_array('site_config',$param)){
    		$where['name']=$param['site_config'];
    	}
    	if(in_array('sms_config',$param)){
    		$where['name']=$param['sms_config'];
    	}
    	if(in_array('wechat_config',$param)){
    		$where['name']=$param['wechat_config'];
    	}
    	if(in_array('payment_config',$param)){
    		$where['name']=$param['payment_config'];
    	}
    	if(in_array('three_config',$param)){
    		$where['name']=$param['three_config'];
    	}
    	$value['value']=serialize($param);
    	$list=Db::name('admin_system')->where($where)->update($value);
    		$this->success('保存成功' , url('index'));
    }
    
  
    
}
